<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserDeviceidTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_device', function (Blueprint $table) {
            $table->increments('id');
            $table->char('device_id', 40)->comment('设备ID');
            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->timestamps();
            $table->tinyInteger('status')->default(1)->comment('设备状态:1-正常0-冻结');
            $table->index('user_id', 'user_id');
            $table->index('device_id', 'device_id');
            $table->index(['user_id', 'device_id'], 'user_device');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('user_device', function (Blueprint $table) {
            //
        });
    }
}
